package com.example.netlib.loading.single;

import android.app.Activity;
import android.app.Application;
import android.util.Log;

import com.example.netlib.loading.LoadingDialog;
import com.szlanyou.thirdsdk.retrofit.loading.NetLoadingStateAction;

/**
 * @author 陈章
 * create at 2020/11/19 16:23
 * desc:Dialog形式的进度框(单例)
 */
public class SingleDialogLoadingAction extends NetLoadingStateAction {
    private static final String TAG = "DialogLoadingAction";
    private SingleLoadingDialog loadingDialog;
    public SingleDialogLoadingAction(Application application) {
        super(application);
        loadingDialog = new SingleLoadingDialog(application);
    }

    @Override
    public boolean isShowing() {
        if(loadingDialog == null){
            return false;
        }
        return loadingDialog.isShowing();
    }

    @Override
    public void showLoading(String loadingTip) {
        if(loadingDialog == null){
            return;
        }
        if(null == loadingTip){
            loadingDialog.showLoading(loadingTip);
        }else{
            loadingDialog.showLoading();
        }
    }

    @Override
    public void showLoading() {
        if(loadingDialog == null){
            return;
        }
        loadingDialog.showLoading();
    }

    @Override
    public void hideLoading() {
        if(loadingDialog == null){
            return;
        }
        loadingDialog.hideLoading();
    }

    @Override
    public void showFailure(Throwable e) {

    }

    @Override
    public void showFailure(Throwable e, String failureTip) {

    }

    @Override
    public void releaseLoading() {
        loadingDialog = null;
    }

}
